/************************************************************************************************
 * test examples of 100 interesting program in C
 * test 007.c
 * 100! ends with how many '0'?
 ***********************************************************************************************/

#include <stdio.h>

/*
 *
 */

#define MAX 1000000

int main()
{
    int i = 0, j = 0, count = 0;
    for (i = 5; i <= MAX; i += 5)
    {
        count++;
        // although this method is already so slow
        // j % 5 == 0 dectection is still need
        for (j = i/5; j > 0 && j % 5 == 0; j /= 5)
        if (j % 5 == 0) count++;
    }
    printf("%d\n", count);
    // this method is faster~
    // count 5, 25, 125, ..., then sum
    // the numbers can be divided by 5 were count once and by 25 were count twice...
    count = 0;
    for (i = 5; i <= MAX; i *= 5)
        for (j = i; j <= MAX; j += i)
	    count++;
    printf("%d\n", count);
}

